import { defineStore } from "pinia";
import { ref } from "vue";

export const useTokenStore = defineStore('token',()=>{

    const token = ref('');

    //检测是否是管理员
    const isAdmin = ref(false);

    const setAdmin = (newAdmin)=>{
        isAdmin.value = newAdmin;
    }

    const setToken = (newToken)=>{
        token.value = newToken;
    }

    const removeToken = ()=> {
        token.value = ''
    }

    return {
        token,isAdmin,setToken,removeToken,setAdmin
    }
},{
    persist: true //持久化存储
});